package com.cloud.bc.model.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum AboutEnum {
    AGREEMENT(1, "注册协议"),
    CONTACT(2, "联系我们"),
    INTRODUCTION(3, "关于我们"),
    RECHARGEAGREEMENT(4, "充值协议"),
    VIPEXPLAIN(5, "VIP会员说明"),
    VIPAGREEMENT(6, "VIP会员购买协议"),
    WITHDRAWALEXPLAIN(7, "提现说明"),
    MARKETINGEXPLAIN(8, "分享说明"),
    PAYMENTAGREEMENT(9, "用户支付协议"),
    HELP(10, "帮助"),
    EXCHANGEEXPLAIN(11, "兑换说明"),
    ;
    private int code;
    private String desc;

    AboutEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static AboutEnum getEnum(String desc) {
        for (AboutEnum c : AboutEnum.values()) {
            if (c.getDesc().equals(desc)) {
                return c;
            }
        }
        return null;
    }

    public static AboutEnum getEnum(int index) {
        for (AboutEnum c : AboutEnum.values()) {
            if (c.getCode() == index) {
                return c;
            }
        }
        return null;
    }

    public static List<Map<String, String>> getAllEnum() {
        List<Map<String, String>> list = new ArrayList<>();
        for (AboutEnum c : AboutEnum.values()) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("value", c.getCode() + "");
            map.put("label", c.getDesc());
            list.add(map);
        }
        return list;
    }

}
